package com.edgclub.edg.activity;

import android.support.v7.widget.LinearLayoutManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.edgclub.edg.Constant;
import com.edgclub.edg.R;
import com.edgclub.edg.adapter.ChatBlacklistAdapter;
import com.hyphenate.chat.EMClient;
import com.hyphenate.easeui.EaseConstant;
import com.hyphenate.easeui.dao.DaoHelper;
import com.hyphenate.easeui.dao.UserBeanDao;
import com.hyphenate.easeui.model.UserBean;
import com.jcodecraeer.xrecyclerview.XRecyclerView;

import java.util.ArrayList;
import java.util.List;


/**
 * 支付管理
 */
public class ChatBlacklistActivity extends GzBaseTooolBarActivity implements
        OnClickListener {

    private XRecyclerView recyclerView;
    private int currPage = 1;
    private int pageSize = 20;
    private ChatBlacklistAdapter blacklistAdapter;
    private List<String>blacklist;
    private List<UserBean>userList=new ArrayList<>();
    private ImageView imageView_empty;
    private TextView text_empty;
    private LinearLayout layout_empty;

    @Override
    public int getContentView() {
        return R.layout.activity_group_people  ;
    }
    @Override
    public void setTitleBarView() {
        setCustomActionBar();
        title.setText("小黑屋");
    }
    @Override
    public void initView() {
        recyclerView= (XRecyclerView) findViewById(R.id.recyclerview);
        layout_empty= (LinearLayout) findViewById(R.id.layout_empty);;
        text_empty= (TextView) findViewById(R.id.text_empty);;
        imageView_empty= (ImageView) findViewById(R.id.imageView_empty);;
        text_empty.setText("小黑屋暂时还没有人呢");
        imageView_empty.setImageResource(R.drawable.black_room);
    }
    @Override
    public void initData() {
        try {
            blacklist= EMClient.getInstance().contactManager().getBlackListUsernames();
            if(null==blacklist){
                blacklist=new ArrayList<>();
//                layout_empty.setVisibility(View.GONE);
//            }else{
//                layout_empty.setVisibility(View.VISIBLE);
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
        for(String str:blacklist){
            if(DaoHelper.getInstance(ChatBlacklistActivity.this,Constant.DB_NAME_CHAT).isHas(UserBeanDao.Properties.Imid,str)){
                userList.add((UserBean) DaoHelper.getInstance(this, EaseConstant.DB_NAME_CHAT).getTypeId(UserBeanDao.Properties.Imid,str));
            }
        }
        blacklistAdapter=new ChatBlacklistAdapter(this);
        blacklistAdapter.setDatas(userList);
        if (!"".equals(userList)&&userList.size()>0){
            layout_empty.setVisibility(View.GONE);
        }
        else
        layout_empty.setVisibility(View.VISIBLE);


        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(layoutManager);
        recyclerView.setLoadingMoreEnabled(false);
        recyclerView.setRefreshing(false);
        recyclerView.setPullRefreshEnabled(false);
        recyclerView.setAdapter(blacklistAdapter);
    }



    @Override
    public void onClick(View v) {
        switch (v.getId()) {

            default:
                break;
        }
    }



}
